package ui.face
{

	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.text.TextField;

	import globals.Global;

	import ui.component.Button;
	import ui.component.Label;
	import ui.panel.PanelType;

	import util.StringUtil;
	import util.TextStyle;
	import util.UIUtil;

	public class ScoreFace extends Sprite
	{
		private var silverLabel:Label; //银
		private var goldLabel:Label;
		private var badgeLabel:Label;
		private var _curStep:TextField; //第几关
		private var _curMapName:TextField;

		public function ScoreFace()
		{
			var bitmap:Bitmap;
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("money_bg"));
			bitmap.x = 310;
			bitmap.y = 10;
			this.addChild(bitmap);
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("money_bg"));
			bitmap.x = 420;
			bitmap.y = 10;
			this.addChild(bitmap);
			//bar icon
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("silver_icon"));
			bitmap.x = 288;
			this.addChild(bitmap);
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("gold_icon"));
			bitmap.x = 75;
			bitmap.y = 60;
			this.addChild(bitmap);
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("badge_icon"));
			bitmap.x = 390;
			this.addChild(bitmap);
			//bar label
			silverLabel = new Label(14, 0xFFFFFF, true, "left", true);
			silverLabel.x = 325;
			silverLabel.y = 13;
			this.addChild(silverLabel);
			goldLabel = new Label(14, 0xFFFFFF, true, "left", true);
			goldLabel.x = 110;
			goldLabel.y = 73;
			this.addChild(goldLabel);
			badgeLabel = new Label(14, 0xFFFFFF, true, "left", true);
			badgeLabel.x = 430;
			badgeLabel.y = 13;
			this.addChild(badgeLabel);
			//关卡
			bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("toll_gate_bg"));
			bitmap.x = 627;
			bitmap.y = -3;
			this.addChild(bitmap);
			var waveProgress:Bar = new Bar("scene_progress_front", "scene_progress_bg", true);
			waveProgress.x = 645;
			waveProgress.y = 49;
			waveProgress.textField.defaultTextFormat = TextStyle.getTextFormat(0x000000, 16, true);
			TextStyle.addTextFrame(waveProgress.textField, 0xFFFFFF);
			this.addChild(waveProgress);
			_curStep = new TextField();
			_curStep.width = 133;
			_curStep.defaultTextFormat = TextStyle.getTextFormat(0xf3ce7b, 12, true, "center");
			_curStep.x = 627;
			_curStep.y = 7;
			TextStyle.addTextFrame(_curStep, 0x1f1200);
			this.addChild(_curStep);
			_curMapName = new TextField();
			_curMapName.width = 133;
			_curMapName.defaultTextFormat = TextStyle.getTextFormat(0xFFFFFF, 12, true, "center");
			_curMapName.x = 627;
			_curMapName.y = 25;
			TextStyle.addTextFrame(_curMapName, 0x1f1200);
			this.addChild(_curMapName);
			_curStep.selectable = _curMapName.selectable = false;
//			//TODO测试
//			waveProgress.update(80, 100, true);
//			updateSilver(48000);
//			updateBadge(48000);
//			updateGold(4800);
//			updateWave(12);
//			_curMapName.text = "林中冒险";
		}

		/**银币**/
		public function updateSilver(value:uint):void
		{
			silverLabel.text = value.toString();
		}

		/**功勋**/
		public function updateBadge(value:uint):void
		{
			badgeLabel.text = value.toString();
		}

		/**金币**/
		public function updateGold(value:uint):void
		{
			goldLabel.text = value.toString();
		}

		/**第几关**/
		public function updateWave(value:int):void
		{
			_curStep.text = StringUtil.substitute("第{0}关", value);
		}

		public function updateMapName(mapId:int):void
		{
			_curMapName.text = "林中冒险";
		}
	}
}